package org.i_plus.model.services;

import java.util.List;

import org.i_plus.model.ChatBean;
import org.i_plus.model.dao.ChatDAO_JDBC;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class ChatService {

	private ChatDAO_JDBC dao = null;
	public void setChatDAO(ChatDAO_JDBC dao){
		this.dao = dao;
	}
	
	public void insert(String c_toacc,String c_fromacc,String c_content ){
		ChatBean bean = new ChatBean();
        bean.setC_toacc(c_toacc);
		bean.setC_fromacc(c_fromacc);
		bean.setC_content(c_content);
		dao.insert(bean);
	}
	public List<ChatBean> select(String fromacc,String toacc,int page){
//		ChatBean bean = new ChatBean();
//		bean.setC_fromacc(fromacc);
//		bean.setC_toacc(toacc);
//		dao.update(bean);
		return dao.selectByFromAcc(fromacc, toacc,page);
	}
	
	public static void main(String args[]){
		ApplicationContext context = new ClassPathXmlApplicationContext("beans.config.xml");
		ChatService service = (ChatService)context.getBean("ChatService");
//		List<ChatBean> list = service.select("a19897811", "q19897811");
//		for(ChatBean temp:list)
//			System.out.println(temp.getC_fromacc()+":"+temp.getC_toacc()+":"+temp.getC_time()+":"+temp.getC_content());
	}
	
}
